package com.gengine.resource.info
{
	import com.gengine.core.*;
	import com.gengine.debug.*;
	import flash.display.*;
	
	public class ResourceInfo extends ClassProxy
	{
		protected var loaderInfo:LoaderInfo;
		public var name:String;
		public var time:String;
		public var path:String;
		public var type:String;
		private var _data:Object;
		public var extData:Object;
		public var isLoaded:Boolean;
		public var isLoading:Boolean = false;
		private var _referenceCount:int = 0;
		private var _isDispose:Boolean = false;
		
		public function ResourceInfo(param1:Object = null)
		{
			if (param1)
			{
				this.type = param1.type;
				this.name = param1.name;
				this.time = param1.time;
				this.path = param1.path + "?v=" + param1.time;
				Log.system(this.path);
			}
			
		}
		
		public function get isDispose() : Boolean
		{
			return this._isDispose;
		}
		
		public function set data(param1:Object) : void
		{
			this._data = param1;
			this._isDispose = false;
			
		}
		
		public function addReference() : void
		{
			_referenceCount = _referenceCount + 1;	
			
		}
		
		public function removeReference() : void
		{
			_referenceCount = _referenceCount - 1;			
		}
		
		public function dispose() : void
		{
			this._isDispose = true;
			this._data = null;
			this._referenceCount = 0;
			this.isLoaded = false;
			this.isLoading = false;
			this.extData = null;
			if (this.loaderInfo && this.loaderInfo.loader)
			{
				this.unload(this.loaderInfo);
			}
			
		}
		
		protected function unload(param1:LoaderInfo) : void
		{
			var loaderInfo:* = param1;
			try
			{
				loaderInfo.loader.close();
			}
			catch (e:Error)
			{
			}
			loaderInfo.bytes.clear();
			loaderInfo.loader.unload();
			loaderInfo;
			
		}
		
	}
}
